﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace PaceR.Examples.MVC.Library
{
    public class BaseController : Controller
    {
        protected string CultureCode { get; set; }

        protected override void OnResultExecuting(ResultExecutingContext filterContext)
        {
            base.OnResultExecuting(filterContext);
            if (RouteData.Values["localCode"] != null)
            {
                CultureCode = RouteData.Values["localCode"].ToString().ToLower();
                System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(CultureCode);
                System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CreateSpecificCulture(CultureCode);
            }
        }
    }
}